Interactive & Animated Plots


import holoviews as hv
import uxarray as ux

hv.extension("bokeh")

file_dir = "../../meshfiles/"
/home/runner/miniconda3/envs/cookbook-dev/lib/python3.10/site-packages/dask/dataframe/_pyarrow_compat.py:17: FutureWarning: Minimal version of pyarrow will soon be increased to 14.0.1. You are using 12.0.1. Please consider upgrading.
  warnings.warn(
grid_filename_geoflow = file_dir + "geoflow.grid.nc"
data_filename_geoflow = file_dir + "geoflow.data.nc"
uxds = ux.open_dataset(grid_filename_geoflow, data_filename_geoflow)

v1 = uxds["v1"].nodal_average()

Interactivity

Dynamic Rendering

Tools

v1[0][0].plot.polygons().opts(tools=["hover"], width=900, height=400)
/home/runner/miniconda3/envs/cookbook-dev/lib/python3.10/site-packages/uxarray/plot/dataarray_plot.py:480: UserWarning: Including Antimeridian Polygons may lead to visual artifacts. It is suggested to keep 'exclude_antimeridian' set to True.
  warnings.warn(
v1[0][0].plot.polygons().opts(tools=["hover"], width=900, height=400)
/home/runner/miniconda3/envs/cookbook-dev/lib/python3.10/site-packages/uxarray/plot/dataarray_plot.py:480: UserWarning: Including Antimeridian Polygons may lead to visual artifacts. It is suggested to keep 'exclude_antimeridian' set to True.
  warnings.warn(

An additional tool that can be selected is the ‘lasso_selecttool, which similar to thebox_select` tool can be used to interactively select points.

v1[0][0].plot.points().opts(tools=["hover", "lasso_select"], width=900, height=400)
/home/runner/miniconda3/envs/cookbook-dev/lib/python3.10/site-packages/uxarray/grid/coordinates.py:235: UserWarning: This cannot be guaranteed to work correctly on concave polygons
  warnings.warn(
/home/runner/miniconda3/envs/cookbook-dev/lib/python3.10/site-packages/uxarray/grid/coordinates.py:65: NumbaPendingDeprecationWarning: 
Encountered the use of a type that is scheduled for deprecation: type 'reflected list' found for argument 'node' of function 'normalize_in_place'.

For more information visit https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-reflection-for-list-and-set-types

File "../../../../../miniconda3/envs/cookbook-dev/lib/python3.10/site-packages/uxarray/grid/coordinates.py", line 87:
@njit(cache=ENABLE_JIT_CACHE)
def normalize_in_place(node):
^

  [dx, dy, dz] = normalize_in_place(node_coord)
/home/runner/miniconda3/envs/cookbook-dev/lib/python3.10/site-packages/uxarray/grid/coordinates.py:65: NumbaPendingDeprecationWarning: 
Encountered the use of a type that is scheduled for deprecation: type 'reflected list' found for argument 'object' of function 'impl_np_array.<locals>.impl'.

For more information visit https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-reflection-for-list-and-set-types

File "../../../../../miniconda3/envs/cookbook-dev/lib/python3.10/site-packages/numba/np/arrayobj.py", line 5394:

    def impl(object, dtype=None):
    ^

  [dx, dy, dz] = normalize_in_place(node_coord)
/home/runner/miniconda3/envs/cookbook-dev/lib/python3.10/site-packages/numba/core/ir_utils.py:2172: NumbaPendingDeprecationWarning: 
Encountered the use of a type that is scheduled for deprecation: type 'reflected list' found for argument 'node_coord' of function 'node_xyz_to_lonlat_rad'.

For more information visit https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-reflection-for-list-and-set-types

File "../../../../../miniconda3/envs/cookbook-dev/lib/python3.10/site-packages/uxarray/grid/coordinates.py", line 43:
@njit(cache=ENABLE_JIT_CACHE)
def node_xyz_to_lonlat_rad(node_coord):
^

  warnings.warn(NumbaPendingDeprecationWarning(msg, loc=loc))

HoloMaps

%%capture
hmap = hv.HoloMap(
    {
        i: v1[0][i].plot.rasterize(
            method="polygon",
            exclude_antimeridian=False,
            cmap="coolwarm",
            title=f"v1: Mesh Layer {i}",
            width=700,
            height=350,
        )
        for i in range(20)
    },
    kdims="Mesh Layer",
)
hmap

Animations

# todo